﻿using System;
using System.Collections.Generic;
using System.Security;
using System.Windows.Controls;
using NaireSystem.Api;
using NaireSystem.Api.Dto;
using NaireSystem.Api.VO;
using NaireSystem.Datas;
using NaireSystem.Enums;
using TYBase;

namespace NaireSystem
{
    public class ServerApi
    {
        public static R<List<UserVO>> GetUserList(string name = "")
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(AppData.Url)
                    .SetUrl($"/user/getUserList?name={name}").SetGet().Excute(out string data))
                {
                    return R<List<UserVO>>.Fail(data);
                }
                return data.AsModel<R<List<UserVO>>>();
            }
            catch (Exception ex)
            {
                return R<List<UserVO>>.Fail("获取用户失败!", ex);
            }
        }
        public static R<List<Public_officeVO>> GetListDept()
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(AppData.Url)
                    .SetUrl($"/user/getListDept").SetGet().Excute(out string data))
                {
                    return R<List<Public_officeVO>>.Fail(data);
                }
                return data.AsModel<R<List<Public_officeVO>>>();
            }
            catch (Exception ex)
            {
                return R<List<Public_officeVO>>.Fail("获取用户失败!", ex);
            }
        }

        public static R<List<UserVO>> GetUserListInDept(string deptId)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(AppData.Url)
                    .SetUrl($"/user/getUserListInDept?deptId={deptId}").SetGet().Excute(out string data))
                {
                    return R<List<UserVO>>.Fail(data);
                }
                return data.AsModel<R<List<UserVO>>>();
            }
            catch (Exception ex)
            {
                return R<List<UserVO>>.Fail("获取用户失败!", ex);
            }
        }
       

        public static R<List<QtVO>> GetRandomQt(RadnomQtDto radnomQtDto)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(AppData.Url)
                    .SetUrl($"/qt/getRandomListQusetion?{radnomQtDto.AsQueryData()}")
                    .SetGet().Excute(out string data))
                {
                    return R<List<QtVO>>.Fail(data);
                }
                return data.AsModel<R<List<QtVO>>>();
            }
            catch (Exception ex)
            {
                return R<List<QtVO>>.Fail("获取数据失败!", ex);
            }
        }

 //public static R<List<UserVO>> GetUserList()
        //{
        //    try
        //    {
        //        LocalHttp http = new LocalHttp();
        //        if (!http.SetBaseUri(AppData.Url)
        //            .SetUrl($"/test/getRandomQt?{radnomQtDto.AsQueryData()}")
        //            .SetGet().Excute(out string data))
        //        {
        //            return R<List<UserVO>>.Fail(data);
        //        }
        //        return data.AsModel<R<List<UserVO>>>();
        //    }
        //    catch (Exception ex)
        //    {
        //        return R<List<UserVO>>.Fail("获取数据失败!", ex);
        //    }
        //}
 }
}
